$('#bd').validate({
	rules: {
		username: {
			required: true,
		},
		password: {
			required: true,
		},
	},

	messages: {
		username: {
			required: '账号或手机号不能为空',
		},
		password: {
			required: '密码不能为空',
		},
	},
	submitHandler: function (bd) {
		//   alert("提交事件!");
		$.ajax({
			url: '/hx/login.php',
			type: 'POST',
			data: {
				user: $('.yhm').val(),
				pass: $('.mima').val(),
			},
			success: function (res) {
				res = JSON.parse(res)
				console.log(res)
				if (res.code == 1) {
					setCookie('login', $('.yhm').val(), 300)
					location.href = './cart.html'
					return
				}
				alert('用户名或密码错误')
			},
			error: function (res) {
				res = JSON.parse(res)
				// console.log(res)
			},
		})
	},
})
